const initState = {
  curApp: {},
  list: [],
  processes: []
}

export default (state = initState, action) => {
  switch (action.type) {
    case 'SET_PROCESSES':
      return {
        ...state,
        processes: action.data || []
      }
    case 'SET_CUR_APP':
      return {
        ...state,
        curApp: state.list.find(el => {
          return el.appDefinitionKey === action.appKey
        }) || {}
      }
    case 'SET_APP_LIST':
      return {
        ...state,
        list: action.data || []
      }
    default:
      return state
  }
}